<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
  $( "#listDiv" ).accordion({
	  collapsible: true,
	  active: false,
	  header : '.titleDiv'
  });
  
  $('.titleDiv').each(function(){
	  if($(this).find('.notice_read').val()=='0'){
		  $(this).css('font-weight','bold');
	  }
  }).click(function(){
	  if($(this).find('.notice_read').val()=='0'){
		  $(this).css('font-weight','normal');
		  $.ajax({
		  	type:'post',
			url:'member.do',
			data: "command=readNotice&&notice_no="+$(this).find('.no').val()
		  });
	  }
  });
  
  $('#delSubmit').click(function(){
	  //$('#delForm').submit();
	  $.ajax({
		  type:'post',
			url:'member.do',
			data: $('#delForm').serialize(),
			
			success:function(data){
			  location.reload();
			}
	  });
  });
  
  $('#checkAll').click(function() {
  	if($(this).prop('checked')){
  		$('.notice_no').prop('checked', true);
  	}else{
  		$('.notice_no').prop('checked', false);
  	}
  });
});
</script>
</head>
<body>
<c:import url="my_header.jsp"/><p>
<div>
	<form action="member.do" method="post" id="delForm">
	<input type="hidden" name="command" value="deleteNotice">
	<input type="checkbox" id="checkAll">
	<a href="#" id="delSubmit">삭제</a>
		<div id="listDiv">
			<c:forEach var="noticeReturn" items="${requestScope.noticeList.noticeList}">
				  <input type="checkbox" value="${noticeReturn.notice_no}" name="notice_no" class="notice_no">
				  <div class="titleDiv">
				  	${noticeReturn.notice_title}
				  	<input type="hidden" class="notice_read" value="${noticeReturn.notice_read}">
				  	<input type="hidden" class="no" value="${noticeReturn.notice_no}">
				  </div>
				  <div class="contentDiv">
					  ${noticeReturn.notice_regdate}<br>
					  ${noticeReturn.notice_content}
				  </div>
			</c:forEach>
		</div>
	</form>
	<div>
	<c:set var="page" value="${requestScope.noticeList.pageManager}" />

	<c:if test="${page.currGroup==1}"><img alt="" src="../img/button/page_begin.gif"></c:if>
	<c:if test="${page.currGroup!=1}">
		<a href="member.do?command=${param.command}&&page=1"><img alt="" src="../img/button/page_begin.gif"></a>
	</c:if>

	<c:if test="${page.existOfPreviousGroup}">
		<a href="member.do?command=${param.command}&&page=${page.firstPageInCurrGroup-page.pagePerGroup}">
			<img alt="" src="../img/button/page_prev.gif"></a>
	</c:if>
	<c:if test="${!page.existOfPreviousGroup}"><img alt="" src="../img/button/page_prev.gif"></c:if>

	<c:forEach var="pageIndex" begin="${page.firstPageInCurrGroup}"
		end="${page.lastPageInCurrGroup}">
		<c:if test="${pageIndex==page.currPage}">&nbsp;<font color="#ff6d66">${pageIndex}</font>&nbsp;</c:if>
		<c:if test="${pageIndex!=page.currPage}">
			<a href="member.do?command=${param.command}&&page=${pageIndex}">&nbsp;<font color="#606060">${pageIndex}</font>&nbsp;</a>
		</c:if>
	</c:forEach>

	<c:if test="${page.existOfNextGroup}">
		<a href="member.do?command=${param.command}&&page=${page.lastPageInCurrGroup+1}">
			<img alt="" src="../img/button/page_next.gif"></a>
	</c:if>
	<c:if test="${!page.existOfNextGroup}"><img alt="" src="../img/button/page_next.gif"></c:if>

	<c:if test="${page.currGroup==page.totalGroup}"><img alt="" src="../img/button/page_end.gif"></c:if>
	<c:if test="${page.currGroup!=page.totalGroup}">
		<a href="member.do?command=${param.command}&&page=${page.totalPage}"><img alt="" src="../img/button/page_end.gif"></a>
	</c:if>
</div>
</div>
</body>
</html>